import api from '../modules/api';


export default {
    namespaced:true,
    state:{
        pages:1,
        total:1,
        pageSize:5,
        currentPage:3,
    },
    mutations:{
        //---------------------设置当前页数----------------------
        setCurrentPage(state,newCurrentPage){
            state.currentPage = newCurrentPage;
        },
        //----------------------设置每页显示多少条数据-------------
        setPageSize(state,newPageSize){
            state.pageSize = newPageSize;
            state.currentPage = 1;
        },
    },
    actions:{
        //-----------------获取班主任信息数据---------------------
        async getDirectors(context,newData){
            const data = await api.directors.getDirectors({
                ...newData,
                pageSize:context.state.pageSize,
                currentPage:context.state.currentPage
            })
            context.state.pages = data.data.pages;
            context.state.total = data.data.total;
            return data
        },
        //------------------新增班主任---------------------------
        async addDirectors(context,newData){
            console.log(newData)
            const data = api.directors.addDirectors(newData);
            return data
        },
    },
}